/*-----------------------------------------------------------------
Replication do-file for JPART article entitled "How Do Elected Officials Evaluate Performance? Goal Preferences, Governance Preferences, and the Process of Goal Reprioritization"

Authors: Julian Christensen, Casper M. Dahlmann, Asbjørn Mathiasen, Donald P. Moynihan, and Niels Bjørn Grund Petersen
-----------------------------------------------------------------*/

use "Replication dataset for How Do Elected Officials Evaluate Performance - Goal Preferences, Governance Preferences, and the Process of Goal Reprioritization.dta", clear

/***NOTE TO READER***

This dataset includes the following variables:

- prior1: Item used to measure prior governance preferences: "Many public activities could be produced both better and cheaper by private providers."
- prior2: Item used to measure prior governance preferences: "We should to a larger degree outsource public services (such as child care, elderly care, and hospital treatments)."
- prior3: Item used to measure prior governance preferences: "The public sector is best at providing public services."
- sector_revealed: Dummy variable indicating whether respondents have been asked to evaluate information about school A and school B (0) or a public and private school (1)
- pub_a_highestwellbeing: Dummy variable indicating whether respondents have been asked to evaluate information where the public school/school A performs best with regard to well-being/worst with regard to test scores (1) or information where the private school/school B performs best with regard to well-being/worst with regard to test scores (0)
- prioritizeswellbeing: Dummy variable indicating whether respondents prioritize student well-being (1) or test scores (0) when evaluating the information.
- leftwingparty: Dummy variable indicating whether respondents are from a left-wing party (1) or not (0)

These variables allow readers to reproduce Table 1's models 1 & 3, Figure 3, Figure 4, and Table A2 in the appendix.

For the sake of anonymity, background variables (needed for Table 1's models 2 & 4 and Table A1) have been excluded from the dataset.

*/


/*-----------------------------------------------------------------
CODING OF INDEX: Create index to measure prior governance preferences
-----------------------------------------------------------------*/
*Create "Pro public" index (footnote 4)
recode prior1 prior2 prior3 (6=.)
replace prior1 = . if prior1 > 5 | prior1 < 1
replace prior2 = . if prior2 > 5 | prior2 < 1
recode prior1 prior2 (5=1) (4=2) (3=3) (2=4) (1=5)
alpha prior1 prior2 prior3
generate pro_public = ((prior1+ prior2+ prior3)-3)/12
tab pro_public
histogram pro_public

/*-----------------------------------------------------------------
TABLE 1: Formal test of hypothesis
-----------------------------------------------------------------*/
*Create interaction term
gen pro_publicXsector_revealed = pro_public*sector_revealed
*H1 is tested on groups 1+3 (where the private school / school B performed best on wellbeing/worst on test scores) (Model 1 in Table 1) 
logit prioritizeswellbeing pro_public sector_revealed pro_publicXsector_revealed if pub_a_highestwellbeing==0
*H1 is tested on groups 2+4 (where the public school / school A performed best on wellbeing/worst on test scores) (Model 3 in Table 1) 
logit prioritizeswellbeing pro_public sector_revealed pro_publicXsector_revealed if pub_a_highestwellbeing==1

/*-----------------------------------------------------------------
FIGURE 3: Visual test of hypothesis
-----------------------------------------------------------------*/
*Group 1
logit prioritizeswellbeing pro_public if pub_a_highestwellbeing==0 & sector_revealed==0
margins, at(pro_public = (0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1))
marginsplot, scheme(s2mono)
*Group 3
logit prioritizeswellbeing pro_public if pub_a_highestwellbeing==0 & sector_revealed==1
margins, at(pro_public = (0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1))
marginsplot, scheme(s2mono)
*Group 2
logit prioritizeswellbeing pro_public if pub_a_highestwellbeing==1 & sector_revealed==0
margins, at(pro_public = (0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1))
marginsplot
*Group 4
logit prioritizeswellbeing pro_public if pub_a_highestwellbeing==1 & sector_revealed==1
margins, at(pro_public = (0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1))
marginsplot, scheme(s2mono)

/*-----------------------------------------------------------------
FIGURE 4: Visual test of hypothesis
-----------------------------------------------------------------*/
*Create categorical variable dividing respondents into preference for public sector (1), preference for private sector (3), and no clear sector preference (2)
gen preference = .
replace preference = 1 if pro_public > 0.66 & pro_public < 10000
replace preference = 2 if pro_public > 0.33 & pro_public < 0.66
replace preference = 3 if pro_public < 0.33
*We see how people who prefer public sector prioritize in different groups (Figure 4A)
mean prioritizeswellbeing if sector_revealed==0 &  pub_a_highestwellbeing==0 & preference==1
mean prioritizeswellbeing if sector_revealed==1 &  pub_a_highestwellbeing==0 & preference==1
mean prioritizeswellbeing if sector_revealed==0 &  pub_a_highestwellbeing==1 & preference==1
mean prioritizeswellbeing if sector_revealed==1 &  pub_a_highestwellbeing==1 & preference==1
*We see how people who have no strong preference prioritize in different groups (Figure 4B)
mean prioritizeswellbeing if sector_revealed==0 &  pub_a_highestwellbeing==0 & preference==2
mean prioritizeswellbeing if sector_revealed==1 &  pub_a_highestwellbeing==0 & preference==2
mean prioritizeswellbeing if sector_revealed==0 &  pub_a_highestwellbeing==1 & preference==2
mean prioritizeswellbeing if sector_revealed==1 &  pub_a_highestwellbeing==1 & preference==2
*We see how people who prefer private sector prioritize in different groups (Figure 4C)
mean prioritizeswellbeing if sector_revealed==0 &  pub_a_highestwellbeing==0 & preference==3
mean prioritizeswellbeing if sector_revealed==1 &  pub_a_highestwellbeing==0 & preference==3
mean prioritizeswellbeing if sector_revealed==0 &  pub_a_highestwellbeing==1 & preference==3
mean prioritizeswellbeing if sector_revealed==1 &  pub_a_highestwellbeing==1 & preference==3
*Figure 4 has been made in Excel using the means above

/*-----------------------------------------------------------------
APPENDIX A2: Test using left wing party (instead of pro_public) as independent variable 
-----------------------------------------------------------------*/
gen leftwingXsector_revealed = leftwingparty*sector_revealed
logit prioritizeswellbeing leftwingparty sector_revealed leftwingXsector_revealed if pub_a_highestwellbeing==0
logit prioritizeswellbeing leftwingparty sector_revealed leftwingXsector_revealed if pub_a_highestwellbeing==1
